package com.ztools.pc.controller.sys;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ztools.common.model.pc.sys.RolePermission;
import com.ztools.common.util.common.PageUtil;
import com.ztools.common.util.common.Result;
import com.ztools.pc.mapper.sys.RolePermissionMapper;
import com.ztools.pc.service.sys.RolePermissionService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:一口香菜
 * @Date: 2023/3/5  13:17
 * @Version 1.0
 */
@RestController
@RequestMapping("/sys/role/permission")
public class RolePermissionController {

    @Resource
    private RolePermissionService rolePermissionService;
    @Resource
    private RolePermissionMapper rolePermissionMapper;

    @RequestMapping("/list")
    public Result findList(@RequestBody PageUtil<RolePermission> pageUtil) {
        Page<RolePermission> list = rolePermissionService.findList(pageUtil);
        return list != null ? Result.success("查询成功").data(list) : Result.error();
    }

    @PostMapping("/add-list")
    public Result addList(@RequestBody List<RolePermission> rolePermissionList) {
        boolean b = rolePermissionService.addList(rolePermissionList);
        return b ? Result.success("新增成功") : Result.error("新增失败");
    }

}
